package cn.ultrarisk.scadmin.manager.biz.user.entity;

import cn.ultrarisk.mybatis.extension.annotation.Table;

import java.io.Serializable;
import java.util.ArrayList;
import java.util.LinkedHashMap;
import java.util.List;
import java.util.Map;


/**
 * 权限实体类
 *
 * @author sevendlong(lin23871@163.com)
 * @date 2014/4/14
 * @since V1.0
 */
@Table(table = "privilege", idColumn = Privilege.ID, autoIncrement = false)
public class Privilege implements Serializable {
    private static final long serialVersionUID = -4653896119333995778L;

    public final static String ID = "id";
    public final static String NAME = "name";
    public final static String URL = "url";
    public final static String PARENT_ID = "parent_id";
    public final static String TYPE = "type";
    public final static String PRIORITY = "priority";

    public static final Map<String, String> COLUMN_PROPERTY_MAP = new LinkedHashMap<String, String>();

    static {
        COLUMN_PROPERTY_MAP.put(ID, "id");
        COLUMN_PROPERTY_MAP.put(NAME, "name");
        COLUMN_PROPERTY_MAP.put(URL, "url");
        COLUMN_PROPERTY_MAP.put(PARENT_ID, "parentId");
        COLUMN_PROPERTY_MAP.put(TYPE, "type");
        COLUMN_PROPERTY_MAP.put(PRIORITY, "priority");
    }

    /**
     * id
     */
    private Integer id;
    /**
     * 名称
     */
    private String name;
    /**
     * url
     */
    private String url;
    /**
     * 上级id
     */
    private Integer parentId;
    /**
     * 类型
     */
    private Integer type;
    /**
     * 优先级
     */
    private Integer priority;
    /**
     * 子菜单
     */
    private List<Privilege> children;

    public Integer getId() {
        return id;
    }

    public void setId(Integer id) {
        this.id = id;
    }

    public String getName() {
        return name;
    }

    public void setName(String name) {
        this.name = name;
    }

    public String getUrl() {
        return url;
    }

    public void setUrl(String url) {
        this.url = url;
    }

    public Integer getParentId() {
        return parentId;
    }

    public void setParentId(Integer parentId) {
        this.parentId = parentId;
    }

    public Integer getType() {
        return type;
    }

    public void setType(Integer type) {
        this.type = type;
    }

    public Integer getPriority() {
        return priority;
    }

    public void setPriority(Integer priority) {
        this.priority = priority;
    }

    public List<Privilege> getChildren() {
        return children;
    }

    public void setChildren(List<Privilege> children) {
        this.children = children;
    }

    public void addChild(Privilege child) {
        if (this.children == null) {
            this.children = new ArrayList<Privilege>();
        }
        this.children.add(child);
    }
}